package com.qf.student.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author YaoJiXing
 * created 2022/11/21 16:36
 */
@Configuration
public class KnifeConfig {

    /**
     * @return 配置说明文档api的风格
     */
    @Bean
    public Docket buildDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(buildApiInfo())
                .select()
                // 要扫描的API(Controller)基础包
                .apis(RequestHandlerSelectors.basePackage("com.qf.student.controller"))
                // 只包含请求路径为 emp 的
                // .paths(PathSelectors.ant("/emp/**"))
                // 所有包请求路径都包含
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * API 借口文档的信息
     * @return
     */
    private ApiInfo buildApiInfo() {
        // 开发者描述信息
        Contact contact = new Contact("千峰教育","https://www.qianfen.com","qianfen@qq.com");
        return new ApiInfoBuilder()
                .title("千峰教育API文档")
                .termsOfServiceUrl("https://qianfen.com")
                .description("平台管理服务api")
                .contact(contact)
                .version("1.0.0")
                .build();
    }


}
